package o;

import android.content.Context;
import com.huawei.appgallery.forum.base.card.bean.ImageInfo;
import com.huawei.appgallery.forum.base.card.bean.Post;
import com.huawei.appgallery.forum.base.card.bean.PostTime;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.appgallery.forum.section.node.TempForumPostNode;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.util.ArrayList;
import java.util.List;

public class cax extends brv {
    private boolean ˋ;
    public Long ˏ;

    public /* synthetic */ chz ॱ(long j) {
        return ˋ(j);
    }

    public cax(Context context, boolean z) {
        super(context);
        this.ˋ = z;
    }

    public cah ˋ(long j) {
        chz ॱ = super.ॱ(j);
        if (ॱ instanceof cah) {
            return (cah) ॱ;
        }
        return null;
    }

    public chz ˋ(long j, int i, int i2, List<CardBean> list) {
        chz ˋ = ˋ(j);
        if (ˋ == null) {
            cie ˋ2 = cib.ˋ(this.ʼ, i);
            if (ˋ2 == null) {
                return null;
            }
            ˋ = new cah(j, ˋ2, i2, list);
            int i3 = this.ͺ;
            this.ͺ = i3 + 1;
            ˋ.ˊ(i3);
            this.ॱॱ.add(ˋ);
        }
        if (!(ˋ.ˋ instanceof TempForumPostNode) || !this.ˋ) {
            return ˋ;
        }
        this.ˏ = Long.valueOf(j);
        return ˋ;
    }

    private boolean ˋ(can o_can) {
        if (this.ˏ == null || o_can == null) {
            return false;
        }
        chz ˋ = ˋ(this.ˏ.longValue());
        List arrayList = new ArrayList();
        arrayList.add(o_can);
        ˋ.ˊ(arrayList);
        return true;
    }

    public void ˊ(byd o_byd, String str) {
        if (o_byd != null) {
            can o_can = new can();
            User user = new User();
            UserSession instance = UserSession.getInstance();
            user.ॱ(1);
            user.ˎ(instance.getNickname());
            user.ˋ(instance.getHeadUrl());
            ˋ(user);
            o_can.ˎ(user);
            o_can.ˎ(str);
            Post post = new Post();
            post.ˊ(o_byd.ˏ());
            post.ॱ(o_byd.ॱ());
            List<byf> ˋ = o_byd.ˋ();
            StringBuilder stringBuilder = new StringBuilder();
            List arrayList = new ArrayList();
            if (ˋ != null && ˋ.size() > 0) {
                for (byf o_byf : ˋ) {
                    if (o_byf.ॱ() == 1) {
                        stringBuilder.append(o_byf.ˏ());
                    } else if (o_byf.ॱ() == 0) {
                        byl ˎ = o_byf.ˎ();
                        if (!(ˎ == null || "image/gif".equals(ˎ.ˊॱ()))) {
                            ImageInfo imageInfo = new ImageInfo();
                            imageInfo.ˊ(o_byf.ˎ().ʽ());
                            arrayList.add(imageInfo);
                        }
                    }
                }
            }
            post.ˏ(ˋ(stringBuilder.toString()));
            post.ˏ(arrayList);
            post.ˏ(1);
            PostTime postTime = new PostTime();
            postTime.ॱ(String.valueOf(System.currentTimeMillis()));
            postTime.ˊ(String.valueOf(System.currentTimeMillis()));
            post.ˏ(postTime);
            post.ˎ("forum|topic_detail|" + post.ˏ());
            o_can.ˎ(post);
            o_can.ॱ(post.ͺ());
            o_can.ˋ(true);
            ˋ(o_can);
        }
    }

    private void ˋ(User user) {
        cbc ˊ = ((cbd) fho.ˏ().ˋ("User").ॱ(cbd.class)).ˊ();
        if (ˊ != null) {
            user.ˊ(ˊ.ˎ());
            user.ˏ(ˊ.ˏ());
        }
    }

    private String ˋ(String str) {
        if (!dof.ॱ(str)) {
            try {
                str = str.replaceAll("[\\t\\n\\r]+", HwAccountConstants.BLANK);
            } catch (Exception e) {
                bqx.ˋ("SectionTabDataProvider", "getPostContent error");
            }
        }
        return str;
    }
}
